
#ifndef __GEONEIGHBOURS_H__
#define __GEONEIGHBOURS_H__

#include "GeoH3DNeighboursNode.h"
#include "FieldTemplates.h"
#include <GL/glew.h>
#include "MFInt32.h"

namespace H3D {

  class H3DAPI_API GeoNeighbours : public GeoH3DNeighboursNode {
  public:

    /// Constructor
    GeoNeighbours( Inst< SFNode >  _metadata = 0,
            Inst< MFInt32 >  _vector   = 0 );

    /// Return a list of indexes, which describes the positions of each neighbourhood information per coordinate.
    vector< unsigned int > getNeighboursIndexes() const;

    virtual vector< unsigned long > getNeighbours( unsigned int index );

    virtual const vector< unsigned long > getNeighbours( unsigned int index ) const;

    virtual unsigned int nrAvailableNeighbours( unsigned int index ) {
		std::vector< unsigned int > indexes(getNeighboursIndexes());
		return (index==indexes.size()-1 ? vector->getValue().size() : indexes[index+1]) - indexes[index];
    }

    /// A vector of GeoNeighbours. A neighbour is equal to coordinate index.
    /// Each coordinate neighbourhood is separeted with -1, a value which cannot be an index.
    /// <b>Access type: </b> inputOutput
    auto_ptr< MFInt32 >  vector;

    /// The H3DNodeDatabase for this node.
    static H3DNodeDatabase database;
  };
}

#endif
